import 'dart:io';
import 'dart:isolate';


/// flutter support not well yet
void main(dynamic args, SendPort port1) {
  print('isolate_spawn_uri start, init args: $args');

  final receivePort = ReceivePort();
  final port2 = receivePort.sendPort;
  receivePort.listen((dynamic message) {
    print('isolate_spawn_uri receive message: $message  from root isolate');
  });

  /// isolate_spawn_uri的SendPort发送到root isolate,用于root isolate向该isolate传递
  port1.send([0, port2]);
  /// 模拟耗时10秒
  sleep(Duration(seconds: 10));
  port1.send([1, 'isolate_spawn_uri excute finish']);
}
